﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AMS.Database;
using AMS.Business;

namespace AMS
{
    public partial class frmRequestors : BaseForm
    {
        public frmRequestors()
        {
            InitializeComponent();

            base.isSingleton = true;
            base.guid = new Guid("{EAABD088-DAEA-4597-9A6B-88922901DDC3}");
        }

        private void Requestors_Load(object sender, EventArgs e)
        {
            try
            {
                BindData();
            }
            catch (Exception ex)
            {
                base.internalFormManager.ShowError(ex);
            }
        }

        private void BindData()
        {
            grdRequestors.DataSource = null; ;
            BindingSource bindingSource = new BindingSource();
            grdRequestors.DataSource = bindingSource;
            bindingSource.DataSource = DataAccess.GetRequestorListFull();

            FormatDataGrid();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            base.DestroyForm(this);
        }

        private void FormatDataGrid()
        {
           foreach( DataGridViewRow r in grdRequestors.Rows)
           {
               // Country formateren; indien leeg dan is het "België"
               if (r.Cells["colCountry"].Value.ToString() == String.Empty)
               {
                   r.Cells["colCountry"].Value = "België";
               }
           }
        }
    }
}
